package com.oplink.webbase.modules.invoicing.utils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.oplink.webbase.common.utils.SpringContextHolder;
import com.oplink.webbase.modules.invoicing.dao.GoodsDao;
import com.oplink.webbase.modules.invoicing.entity.Goods;
import com.oplink.webbase.modules.sys.entity.Dict;

/**
 * 
 * Title:
 * Description:
 * Copyright: Copyright (c) 2015
 * Company: Oplink Communications
 * 
 * @author
 * @serialData 2015-3-11 下午3:04:43
 * @version 1.0
 */

public class GoodsUtil {
	private static GoodsDao goodsDao = SpringContextHolder.getBean(GoodsDao.class);

	public static List<Dict> getAllGoods() {
		List<Dict> listOut = new ArrayList<Dict>();
		Iterator<Goods> iter = goodsDao.findAll().iterator();
		while (iter.hasNext()) {
			Goods goods = iter.next();
			Dict dict = new Dict();
			dict.setLabel(goods.getGoodsName());
			dict.setValue(goods.getGoodsId().toString());
			listOut.add(dict);
		}
		return listOut;
	}
}
